package com.wnxy.sddfp.common.util;

import com.wnxy.sddfp.common.constant.UserConstant;
import com.wnxy.sddfp.common.model.vo.user.TokenVo;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class TokenUtils {
    public static TokenVo getTokenVo(){
        ServletRequestAttributes requestAttributes =
                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        return new TokenVo(
                request.getHeader(UserConstant.TOKEN_USERID),
                request.getHeader(UserConstant.TOKEN_PHONE));
    }
}
